import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, Length } from 'class-validator';
import { IsMobilePhone } from 'src/utils/Validator';

export class SmsDto {
  @ApiProperty({
    type: String,
    example: '13800138000',
    description: '手机号',
  })
  @IsNotEmpty({
    message: '手机号不能为空',
  })
  @IsMobilePhone({
    message: '手机号码格式不正确',
  })
  phone: string;

  @ApiProperty({
    type: String,
    example: 'EGNR',
    description: '图片验证码',
  })
  @IsNotEmpty({
    message: '图片验证码不能为空',
  })
  @Length(6, 6, {
    message: '图片验证码必须是6位字符',
  })
  captcha: string;

  @ApiProperty({
    enum: ['register', 'login'],
    description: 'register:注册 login:登录',
    example: 'register',
  })
  @IsNotEmpty({
    message: '类型不能为空',
  })
  @IsEnum(['register', 'login'], {
    message: 'type类型必须是register或login',
  })
  type: string;
}
